Skip to content

Conversation

coderfender
Copy link
Contributor

@coderfender coderfender commented Aug 31, 2025

Which issue does this PR close?

Closes #2233

Rationale for this change

Spark performs lazy evaluation with the coalesce function while comet/ data fusion does not . This causes different behavior when one of the expressions errors out (ex: division by zero) .

What changes are included in this PR?

This change essentially converts spark's coalesce nodes into case statement node (to leverage current comet functionality) . This change is minimal and easy to revert once the upstream datafusion bug is fixed.

How are these changes tested?

Unit tests to ensure lazy evaluation is performed

@coderfender
Copy link
Contributor Author

@andygrove , Please kick off the CI whenever you get a chance

@coderfender coderfender marked this pull request as ready for review August 31, 2025 22:42
@coderfender coderfender force-pushed the lazy_eval_coalesce_case_fallback_statement branch from cd2c3cb to f0055e3 Compare September 1, 2025 21:10
@coderfender
Copy link
Contributor Author

Rebased with main branch .

@coderfender coderfender force-pushed the lazy_eval_coalesce_case_fallback_statement branch from f0055e3 to e0cdb86 Compare September 2, 2025 22:54
@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.91%. Comparing base (f09f8af) to head (206432a).
⚠️ Report is 451 commits behind head on main.

Files with missing lines Patch % Lines
...ain/scala/org/apache/comet/serde/conditional.scala 73.91% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2270      +/-   ##
============================================
+ Coverage     56.12%   57.91%   +1.78%     
- Complexity      976     1290     +314     
============================================
  Files           119      146      +27     
  Lines         11743    13367    +1624     
  Branches       2251     2373     +122     
============================================
+ Hits           6591     7741    +1150     
- Misses         4012     4369     +357     
- Partials       1140     1257     +117     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderfender
Copy link
Contributor Author

@andygrove please take a look whenever you get a chance .

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @coderfender. This is looking good. I will review tomorrow.

@coderfender
Copy link
Contributor Author

Thank you very much @andygrove

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @coderfender

@coderfender coderfender force-pushed the lazy_eval_coalesce_case_fallback_statement branch from 10f6557 to 206432a Compare September 3, 2025 19:18
@andygrove andygrove merged commit 22583c1 into apache:main Sep 3, 2025
93 checks passed
@coderfender
Copy link
Contributor Author

Thank you for merging the PR @andygrove . I will rebase ANSI arithmetic changes PR with main branch and update there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COALESCE does not perform lazy evaluation (unlike Spark)
3 participants